package com.justcan.demo.cartoon.spine;

import android.content.Context;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.utils.Scaling;
import com.badlogic.gdx.utils.viewport.ScalingViewport;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.badlogic.gdx.utils.viewport.Viewport;

import javax.microedition.khronos.opengles.GL10;

/**
 * Created by justcan on 2018/1/19.
 */

public class JustcanDemo extends ApplicationAdapter {

    private Stage stage;
    private BitmapFont bitmapFont;
    private Label.LabelStyle labelStyle;
    private Label label;

    public JustcanDemo(Context context) {

    }

    @Override
    public void create() {
        bitmapFont = new BitmapFont(Gdx.files.internal("justcan.fnt"), Gdx.files.internal("justcan.png"), false);
        labelStyle = new Label.LabelStyle(bitmapFont, bitmapFont.getColor());
        label = new Label("我们是", labelStyle);

        ScreenViewport viewport = new ScreenViewport();
        viewport.setScreenSize(100, 100);
        stage = new Stage(viewport);
        label.setPosition(100, 100);
        label.setColor(Color.GREEN);

        stage.addActor(label);

        Gdx.input.setInputProcessor(stage);
    }

    @Override
    public void resize(int width, int height) {
        super.resize(width, height);
    }

    @Override
    public void render() {
        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

        stage.act();
        stage.draw();
    }

    @Override
    public void dispose() {
        super.dispose();
    }
}
